#include "fps.h"
#include <SDL.h>

Fps::Fps()
{
	_old_time = 0;
	_last_time = 0;
	_speed_factor = 0;
	_frames = 0;
	_num_frames = 0;
}

Fps::~Fps()
{
}

void Fps::OnLoop()
{
	if((_old_time + 1000) < SDL_GetTicks())
	{
		_old_time = SDL_GetTicks();
		_num_frames = _frames;
		_frames = 0;
	}

	_speed_factor = ((SDL_GetTicks() - _last_time) / 1000.0f) * 32.0f;

	_last_time = SDL_GetTicks();

	_frames++;
}

int Fps::GetFps()
{
	return _num_frames;
}

float Fps::GetSpeedFactor()
{
	return _speed_factor;
}
